<template>
  <div class="member-order" v-if="order">
    <!-- 操作栏 -->
    <OrderDetailAction :order="order"/>
    <!-- 步骤条-->
    <DetailStep :order="order"/>
    <!--  物流: 3为待收货、4为待评价、5为已完成-->
    <Suspense>
      <template #default>
        <DetailLogistics v-if="[3,4,5].includes(order.orderState)" :order="order"/>
      </template>
      <template #fallback>loading</template>
    </Suspense>
  <!--  详情信息-->
    <OrderInfo :order="order"/>
  </div>
</template>

<script>
import OrderDetailAction from '@/views/member/order/components/detail-action'
import { ref } from 'vue'
import { useRoute } from 'vue-router'
import { findOrderDetail } from '@/api/order'
import DetailStep from '@/views/member/order/components/detail-step'
import DetailLogistics from '@/views/member/order/components/detail-logistics'
import OrderInfo from '@/views/member/order/components/detail-info'

export default {
  name: 'MemberOrderDetail',
  components: {
    OrderInfo,
    DetailLogistics,
    DetailStep,
    OrderDetailAction
  },
  setup () {
    const route = useRoute()
    const order = ref(null)
    findOrderDetail(route.params.id).then(data => {
      order.value = data.result
    })
    return { order }
  }
}
</script>

<style scoped lang="less">
.member-order{
  padding: 20px;
  min-height: 400px;
  background-color: white;
}
</style>
